Skip to content

Guard copy actions when no report is generated#576

Open
Myst1C13 wants to merge 1 commit intofossasia:mainfrom
Myst1C13:codex-fix-empty-copy-state
Open

Guard copy actions when no report is generated#576
Myst1C13 wants to merge 1 commit intofossasia:mainfrom
Myst1C13:codex-fix-empty-copy-state

Conversation

@Myst1C13
Copy link
Copy Markdown

@Myst1C13 Myst1C13 commented Apr 19, 2026

Summary

  • prevent the copy button from showing Copied! when no scrum report has been generated
  • guard keyboard shortcut copy and insert actions the same way
  • reuse a shared report-content check before triggering copy behavior

Testing

  • verified the change locally in src/scripts/popup.js
  • repo-wide Biome check currently reports pre-existing formatting and config issues unrelated to this change

Summary by Sourcery

Guard copy-related actions behind a shared scrum report content check to avoid acting when no report is available.

Bug Fixes:

  • Prevent the copy button from indicating success when no scrum report content exists.
  • Block keyboard shortcut copy and insert actions when there is no scrum report content.

Enhancements:

  • Introduce a reusable helper to detect the presence of scrum report content and apply it across copy and insert flows.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 19, 2026

Reviewer's Guide

Adds a shared helper to determine whether a scrum report has meaningful content and uses it to guard copy/insert actions (including keyboard shortcuts) so they do nothing when no report is present, avoiding misleading "Copied!" behavior.

Sequence diagram for guarded copy via keyboard shortcut

sequenceDiagram
    actor User
    participant Document
    participant KeydownHandler
    participant hasScrumReportContent
    participant copyBtn
    participant ScrumReportEl

    User->>Document: Press modifier+Shift+Y
    Document->>KeydownHandler: keydown event
    KeydownHandler->>KeydownHandler: Check modifier, shift, alt, repeat, copyBtn state
    KeydownHandler->>hasScrumReportContent: hasScrumReportContent()
    hasScrumReportContent->>ScrumReportEl: getElementById(scrumReport)
    alt Scrum report element missing
        hasScrumReportContent-->>KeydownHandler: false
        KeydownHandler-->>Document: Do nothing
    else Scrum report element present
        hasScrumReportContent->>ScrumReportEl: Read textContent and innerHTML
        hasScrumReportContent-->>KeydownHandler: true if non empty
        alt Report has content
            KeydownHandler->>Document: preventDefault()
            KeydownHandler->>Document: showShortcutNotification(copyingReportNotification)
            KeydownHandler->>copyBtn: _triggeredByShortcut = true
            KeydownHandler->>copyBtn: click()
        else Report empty
            KeydownHandler-->>Document: Do nothing
        end
    end
Loading

Sequence diagram for guarded copy via button click

sequenceDiagram
    actor User
    participant copyBtn
    participant hasScrumReportContent
    participant ScrumReportEl
    participant Document

    User->>copyBtn: click
    copyBtn->>ScrumReportEl: getElementById(scrumReport)
    copyBtn->>hasScrumReportContent: hasScrumReportContent(ScrumReportEl)
    alt No scrum report content
        hasScrumReportContent-->>copyBtn: false
        copyBtn->>copyBtn: _triggeredByShortcut = false
        copyBtn-->>User: No feedback, no copy
    else Scrum report has content
        hasScrumReportContent-->>copyBtn: true
        copyBtn->>Document: createElement(div) as tempDiv
        copyBtn->>tempDiv: innerHTML = ScrumReportEl.innerHTML
        copyBtn->>Document: appendChild(tempDiv)
        copyBtn->>Document: select tempDiv content
        copyBtn->>Document: execCommand(copy)
        copyBtn->>Document: removeChild(tempDiv)
        copyBtn-->>User: Show Copied feedback
    end
Loading

Flow diagram for hasScrumReportContent helper logic

flowchart TD
    A["Call hasScrumReportContent with optional scrumReportEl or default getElementById(scrumReport)"] --> B{scrumReportEl exists?}
    B -- No --> C[Return false]
    B -- Yes --> D["Read textContent and innerHTML from scrumReportEl"]
    D --> E{"Any non empty trimmed content?"}
    E -- No --> C
    E -- Yes --> F[Return true]
Loading

File-Level Changes

Change Details Files
Introduce a shared helper to detect whether the scrum report has any non-empty content and reuse it across copy/insert paths.
  • Add hasScrumReportContent(scrumReportEl) utility that checks textContent and innerHTML for non-whitespace content, safely handling a missing element.
  • Default the helper to look up #scrumReport when no element is passed, for convenient use from global handlers.
src/scripts/popup.js
Guard copy and insert actions (buttons and keyboard shortcuts) so they only fire when a non-empty scrum report exists.
  • Replace direct content truthiness check before insertEmailBtn shortcut with hasScrumReportContent(scrumReportEl).
  • Short-circuit the Copy button click handler when the scrum report is empty or missing, ensuring _triggeredByShortcut is reset and no copy feedback is shown.
  • Extend keyboard shortcut handlers for copy (modifier+Shift+Y) and insert (modifier+Shift+M) to require hasScrumReportContent() before triggering actions, preventing notifications and side effects when there is no report.
src/scripts/popup.js

Possibly linked issues

  • #0: PR adds content checks for copy/insert actions, fixing the empty-report 'Copied!' state described in issue

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions Bot added the javascript Pull requests that update javascript code label Apr 19, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Myst1C13
Copy link
Copy Markdown
Author

Fixed the empty-report copy state issue by guarding copy/insert actions when no report content is present. Happy to make any follow-up changes if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant